﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using Fonour.Domain.Entities;

namespace Fonour.Domain.IRespositories
{
    public interface IRepository
    {

    }
    //自定义主键的类型

    public interface IRepository<TEntity, TPrimaryKey> : IRepository where TEntity : Entity<TPrimaryKey>
    {
        List<TEntity> GetAllList();
        List<TEntity> GetAllList(Expression<Func<TEntity, bool>> predicate);

        TEntity Get(TPrimaryKey id);

        TEntity FirseOrDefault(Expression<Func<TEntity, bool>> predicate);

        TEntity Insert(TEntity entity);

        TEntity Update(TEntity entity);

        TEntity InsertOrUpdate(TEntity entity);

        void Delete(TEntity entity);

        void Delete(TPrimaryKey id);
        void Delete(Expression<Func<TEntity, bool>> where, bool autoSave = true);

        IQueryable<TEntity> LoadPageList(int startPage, int pageSize, out int rowCount,
            Expression<Func<TEntity, bool>> where, Expression<Func<TEntity, object>> order);

        void Save();
    }
    //默认以GUID作为主键
    public interface IRepository<TEntity> : IRepository<TEntity, Guid> where TEntity : Entity
    {

    }
}
